package cn.zhaoyuening.schoolmates.web.general;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import cn.zhaoyuening.schoolmates.domain.ArticleCategory;
import cn.zhaoyuening.schoolmates.service.ArticleCategoryService;
import cn.zhaoyuening.schoolmates.utils.JsonUtils;
import cn.zhaoyuening.schoolmates.utils.ResponceResult;
import cn.zhaoyuening.schoolmates.utils.page.PageBean;
import net.minidev.json.JSONObject;

@RestController
public class ArticleCategoryController {
	@Autowired
	private ArticleCategoryService articleCategoryService;

	@RequestMapping(value="articleCategoryList",method=RequestMethod.GET)
	public String findAll() {
		List<ArticleCategory> list = articleCategoryService.findAll();
		return JsonUtils.objectToJson(list);
	}
	
	@RequestMapping(value="articleCategorys",method=RequestMethod.GET)
	public String articleCategory( String order,Integer offset, Integer limit) {
		Long total = articleCategoryService.getTotalRecord();
		List<ArticleCategory> list = articleCategoryService.findAll(null, null, offset, limit,"id "+order);
		PageBean<ArticleCategory> pageBean = new PageBean<>(total, list);
		return JsonUtils.objectToJson(pageBean);
	}
	

	
}
